package com.he.service.signin;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.he.dao.SigninMapper;
import com.he.pojo.Signin;
import com.he.pojo.SigninExample;
/**
 * 
 * @类名：SigninServiceImpl
 * @描述：签到Service实现类
 * @日期：2018年8月18日 下午7:56:56
 */
@Service
public class SigninServiceImpl implements SigninServiceI {
	@Autowired
	SigninMapper signinMapper;
	@Override
	public List<Signin> getPageSignins(SigninExample signinExample, Signin signin) {
		//如果withPage属性值为1代表要分页
		if(signin.getWithPage()==1) {
			PageHelper.startPage(signin.getPageNo(),signin.getPageSize());
		}
		return signinMapper.selectByExample(signinExample);
	}
	
	@Override
	public List<Signin> getNoPageSignins(SigninExample signinExample) {
		return signinMapper.selectByExample(signinExample);
	}
	
	@Override
	public Signin getSigninById(int id) {
		//通过id查询签到
		return signinMapper.selectByPrimaryKey(id);
	}

	@Override
	public int insert(Signin signin) {
		//仅插入不为空指针的签到数据
		return signinMapper.insertSelective(signin);
	}

	@Override
	public int update(Signin signin) {
		//仅更新不为空指针的签到数据
		return signinMapper.updateByPrimaryKeySelective(signin);
	}

	@Override
	public int delete(int id) {
		//删除一条签到记录
		return signinMapper.deleteByPrimaryKey(id);
	}

}
